require 'test/unit'
require 'm3g'

class Test_AnimationController < Test::Unit::TestCase
  def setup
  end

  def teadown
  end

  def test_default_variables
    ctrl = M3G::AnimationController.new

    assert_equal 0, ctrl.active_interval.start
    assert_equal 0, ctrl.active_interval.end
    assert_equal 0, ctrl.ref_world_time
    assert_equal 1, ctrl.speed
    assert_equal 1, ctrl.weight
  end

  def test_set_variables
    ctrl = M3G::AnimationController.new
    ctrl.active_interval = [1000, 5000]
    ctrl.position        = [10, 2000]
    ctrl.weight          = 0.5
    ctrl.speed           = [1, 2000]

    assert_equal 1000, ctrl.active_interval.start
    assert_equal 5000, ctrl.active_interval.end
    assert_equal 2000, ctrl.ref_world_time
    assert_equal 1   , ctrl.speed
    assert_equal 0.5 , ctrl.weight

    assert_equal 10, (ctrl.position 2000)
    assert_equal 20, (ctrl.position 2010)

    ctrl.speed  = [2, 2000]

    assert_equal 10, (ctrl.position 2000)
    assert_equal 30, (ctrl.position 2010)

    ctrl.speed = [4,2010]

    assert_equal 30, (ctrl.position 2010)
    assert_equal 70, (ctrl.position 2020)
  end

  def test_duplicate
    ctrl1 = M3G::AnimationController.new
    ctrl1.active_interval = [1000, 5000]
    ctrl1.position        = [10, 2000]
    ctrl1.weight          = 0.5
    ctrl1.speed           = [1, 2000]

    ctrl2 = ctrl1.duplicate

    assert_not_equal ctrl1, ctrl2
    assert_equal 1000, ctrl2.active_interval.start
    assert_equal 5000, ctrl2.active_interval.end
    assert_equal 2000, ctrl2.ref_world_time
    assert_equal 1   , ctrl2.speed
    assert_equal 0.5 , ctrl2.weight
  end

end
